<!-- 
	查看页面
 -->
<template>
	<div>
		<div id="container">
			<div class="row">
				<div class="col-md-3">
					<label class="form-label" >任务编号:</label>
					<span v-text="psInspectiontaskMain.inspectiontaskcode"></span>
				</div>
				<div class="col-md-3">
					<label class="form-label">任务名称:</label>
					<span v-text="psInspectiontaskMain.inspectiontaskname"></span>
				</div>
				<div class="col-md-3">
					<label class="form-label">巡检线路:</label>
					<span v-text="psInspectiontaskMain.linecode"></span>
				</div>
				<div class="col-md-3">
					<label class="form-label">起始杆号:</label>
					<span v-text="psInspectiontaskMain.startpolecode"></span>
				</div>
			</div>
			<div class="row">
				<div class="col-md-3">
					<label class="form-label">下发人:</label>
					<span v-text="psInspectiontaskMain.issuedbyname"></span>
				</div>
				<div class="col-md-3">
					<label class="form-label">下发时间:</label>
					<span v-text="psInspectiontaskMain.issuedtime"></span>
				</div>
				<div class="col-md-3">
					<label class="form-label">任务状态:</label>
					<span v-text="{
					    1: '待分配',
					    2: '已分配',
					    3: '执行中',
					    4: '已完成'
					}[psInspectiontaskMain.taskstatus] || ''"></span>
		
				</div>
				<div class="col-md-3">
					<label class="form-label">终止杆号:</label>
					<span v-text="psInspectiontaskMain.endpolecode"></span>
				</div>
		
			</div>
		
			<div class="row">
				<div class="col">
					<label class="form-label">任务完成时间:</label>
					<span v-text=""></span>
				</div>
			</div>
			<div class="row">
				<div class="col">
					<label class="form-label">备注信息:</label>
					<span v-text="psInspectiontaskMain.common"></span>
				</div>
			</div>
			<div class="row">
				<div class="col">
					<label class="form-label">巡检员:</label>
					<span v-for="(item, index) in psInspectorDetail" :key="index" v-text="item.inspectorname"></span>
				</div>
			</div>
		
		
		</div>
		<div id="container" class="conMode">
			<div class="row" v-if="psInspectiontaskMain.taskstatus!=1">
				<div class="col-3 border" style="">
						<div>
							<label class="form-control">巡检线路:</label>
							<el-dropdown size="medium" split-button type="primary" @command="handleCommand">
							    <span v-text="psInspectiontaskMain.linename"></span>
							    <el-dropdown-menu slot="dropdown">
							        <el-dropdown-item v-for="item in psPoleInfoByid" :command="{polecode:item.polecode,poleid:item.id}" :key="item.id" v-text="item.linename"></el-dropdown-item>
							    </el-dropdown-menu>
							</el-dropdown>
						</div>	
						
				</div>
				<div class="col-2 border" style="display: flex; justify-content: center; align-items: center;text-align: center;color:black;">
						<div class=h3>
							==>>>
						</div>
				</div>
				<div class="col-7 border" style="">
					<div >
						<div class="row">
							<div class="col-md-6">
								<label class="form-label" >线路编号:</label>
								<span v-text="queryPstaDeObjs.linecode"></span>
							</div>
							<div class="col-md-6">
								<label class="form-label">杆塔编号:</label>
								<span v-text="queryPstaDeObjs.polecode"></span>
							</div>
						</div>
						<div class="row">
							<div class="col-md-6">
								<label class="form-label" >有无故障:</label>
								<span v-text="queryPstaDeObjs.isbug==1?'有':'无'"></span>
							</div>
							<div class="col-md-6">
								<label class="form-label">完好率:</label>
								<span v-text="queryPstaDeObjs.intactrate"></span>
							</div>
						</div>
						<div class="row">
							<div class="col-md-6">
								<label class="form-label" >缺陷类型:</label>
								<span v-text="queryPstaDeObjs.bugtypename"></span>
							</div>
							<div class="col-md-6">
								<label class="form-label">缺陷级别:</label>
								<span v-text="queryPstaDeObjs.buglevelname"></span>
							</div>
						</div>
						<div class="row">
							<div class="col">
								<label class="form-label" >缺陷描述:</label>
								<span v-text="queryPstaDeObjs.bugdesc"></span>
							</div>
						</div>
						<div class="row">
							<div class="col">
								<label class="form-label" >巡检时间:</label>
								<span v-text="queryPstaDeObjs.inspecttime"></span>
							</div>
						</div>
						<div class="row">
							<div class="col-md-6">
								<label class="form-label" >巡检员:</label>
								<span v-for="(item, index) in psInspectorDetail" :key="index" v-text="item.inspectorname"></span>
							</div>
						</div>
						<div class="row">
							<div class="col-md-6">
								<label class="form-label" >缺陷发现人:</label>
								<span v-text="queryPstaDeObjs.discoverername"></span>
							</div>
							<div class="col-md-6">
								<label class="form-label">发现时间:</label>
								<span v-text="queryPstaDeObjs.discovertime"></span>
							</div>
						</div>
						<div class="row">
							<div class="col-md-6">
								<label class="form-label" >下发人员:</label>
								<span v-text="queryPstaDeObjs.createdby"></span>
							</div>
							<div class="col-md-6">
								<label class="form-label">下发时间:</label>
								<span v-text="queryPstaDeObjs.creationtime"></span>
							</div>
						</div>
					
					</div>
				</div>
			</div>
			<button type="button" class="btn btn-outline-primary" @click="$router.go(-1)">返回</button>
		</div>
	</div>
</template>

<script>
	import {
		queryByPsInspectiontaskMain,
		queryListById,
		psPoleInfoById,
		queryPstaDeObj
	} from '../../config/request.js'
	export default {
		data() {
			return {
				psInspectiontaskMain: {
					
				},
				psInspectorDetail:{
					
				},
				psPoleInfoByid:{
					// 所属线路 的 所有 杆塔
				}
				,
				psId:'',
				selectedLineId:"-1", // 选择的下拉框的id
				queryPstaDeObj:{
					linecode: '',
					            linename: '',
					            taskid: '',
					            taskstatus: '',
					            isbug: 0,
					            poleid: '',
					            polecode: '',
					            discoverercode: '',
					            discoverername: '',
					            bugtype: '',
					            bugtypename: '',
					            buglevel: '',
					            buglevelname: '',
					            intactrate: '',
					            discovertime: '',
					            inspecttime: '',
					            creationtime: '',
					            lastUpdatetime: ''
				} ,// 查询 参数 
				queryPstaDeObjs:{}, //查询出来的对象
			}
		},
		methods: {
			load(){
				queryByPsInspectiontaskMain(this.psId).then(json=>{
					this.psInspectiontaskMain=json.data.queryByObj
					
					
					// 查询巡检员
					queryListById(this.psInspectiontaskMain.inspectiontaskcode).then(json=>{
						console.log(json.data.queryListById)
						this.psInspectorDetail=json.data.queryListById
					})
					
					psPoleInfoById(this.psInspectiontaskMain.lineid).then(json=>{
						console.log(json.data.queryListById)
						this.psPoleInfoByid=json.data.queryListById
					})
					
					
				})
			},
			 handleCommand({polecode, poleid}) {
			         // 在这里处理 polecode 和 poleid
			         console.log('选中的线路名称:', polecode);
			         console.log('选中的线路id:', poleid);
					 
			 		this.queryPstaDeObj.poleid=poleid
			 		this.queryPstaDeObj.linename=this.psInspectiontaskMain.linename 
					
					queryPstaDeObj(this.queryPstaDeObj).then(json=>{
						console.log()
						if(json.data.queryByObj!=null){
							this.queryPstaDeObjs=json.data.queryByObj
						}else{
							this.queryPstaDeObjs={}
							alert("该杆塔暂无数据!")
						}
						
					})
			 }
		},
		mounted() {
			this.load()
		},
		created() {
			this.addInspectiontaskDetailObj = {
			        linecode: '',
			        linename: '',
			        taskid: '',
			        taskstatus: '',
			        isbug: 0,
			        poleid: '',
			        polecode: '',
			        discoverercode: '',
			        discoverername: '',
			        bugtype: '',
			        bugtypename: '',
			        buglevel: '',
			        buglevelname: '',
			        intactrate: '',
			        discovertime: '',
			        inspecttime: '',
			        creationtime: '',
			        lastUpdatetime: ''
			    };
			// 接收参数
		    this.psId = this.$route.query.ps_Id;
		    
		  }
	}
</script>

<style lang="less" scoped>
	#container {
		background-color: #DCDFE6;
		border-radius: 5px;
		margin-top: 5%;
		padding: 20px;
		
	}
	#container div label {
	    font-size: 18px;
		margin-right: 10px; /* 例如，将右边距设置为 10 像素 */
	}
	
	#container div span {
	     font-family: 宋体;
	}
	
</style>